<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

require_once APPPATH . 'models/m_select.php';

/**
 * Модель выборки источников видео
 *
 * @package CoreFramework
 * @version 1.0
 * @author Gennadiy Kozlenko
 */
class M_Select_Sources extends M_Select {
   
   /**
    * Конструктор класса
    *
    * @access public
    * @return M_Select_Sources
    */
   function M_Select_Sources() {
      parent::M_Select();
      $this->load->language('select_sources');
      // Устанавливаем запрос
      $sql = "
         SELECT
            s.id_source AS id,
            s.title,
            COUNT(vt.id_torrent) AS torrents,
            s.status
         FROM
            " . $this->db->dbprefix('sources') . " s
               LEFT JOIN " . $this->db->dbprefix('video_torrents') . " vt ON (vt.id_source = s.id_source)
         WHERE
            s.status <> 'deleted'
         GROUP BY
            s.id_source
      ";
      parent::set_sql($sql);
   } // end M_Select_Sources
   
   /**
    * Установка SQL запроса
    *
    * @access public
    * @param string $table
    */
   function set_sql($sql) {
      
   } // end set_sql
   
}
